/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.yonsei.iwb.sdt.datastructure;

import com.hp.hpl.jena.rdf.model.RDFNode;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Vector;

/**
 *
 * @author JDK
 */
public class TargetInstanceSet extends Hashtable<TargetInstance, Integer>{
    
    public int positive;
    public int negative;
//    private TargetInstanceValueSet tivs;    
    private Hashtable<Integer, String> tivs;
    public TargetInstanceSet(){
        this.tivs = new Hashtable<Integer, String>();
        
    }   
    
    public void putTI(TargetInstance ti, int value){
        ti.setTargetvalue(value);
        this.put(ti, value);        
    }
    
//    public void setTargetInstanceValueSet(TargetInstanceValueSet tivs){
//        this.tivs = tivs;
//    }
//    
//    public TargetInstanceValueSet getTargetInstanceValueSet(){
//        return this.tivs;
//    }
    
    /**
     * set target value set
     * @param vset 
     */
    public void setTargetInstanceValueSet(ArrayList<String> vset){
        for (int i = 0; i < vset.size(); i++) {
            String v = vset.get(i);
            this.tivs.put(i, v);            
//            System.out.println("# value: " +i + " = " + v);
        }
        
    }
    
    public Vector<TargetInstance> getInstanceList(){
        
        Enumeration<TargetInstance> e = this.keys();
        Vector<TargetInstance> rset = new Vector<TargetInstance>();
        while(e.hasMoreElements()){
            TargetInstance r = e.nextElement();
            rset.add(r);
        }        
        return rset;
    }
    
//    public void setTargetInstance(Resource r, RDFNode value){
//        
//    }
    
    
    public TargetInstanceSet(Vector<String> posInstance, Vector<String> negInstance){
//        for (int i = 0; i < posInstance.size(); i++) {
////            System.out.println("positive instance = " + posInstance.get(i));
////            this.put(posInstance.get(i), Boolean.TRUE);
//            this.put(posInstance.get(i), 0);
//            this.positive++;
//        }
//        
//        for (int j = 0; j < negInstance.size(); j++) {
////            System.out.println("negative instance = " + negInstance.get(j));
////            this.put(negInstance.get(j), Boolean.FALSE);
//            this.put(negInstance.get(j), 1);
//            this.negative++;
//        }
    }
    
    
    
    public void printTargetInstanceSet(){        
        Enumeration<TargetInstance> e = this.keys();
        while(e.hasMoreElements()){
            
            TargetInstance r = e.nextElement();
            int v = this.get(r);
            System.out.println("# Instance name : " + r + " , target id : "+ v +"/ target value : "+ this.tivs.get(v));            
            
//            boolean b = this.get(r);            
//            System.out.println("Instance name : " + r + " , target value : "+ b);
        }
        
    }
    
    
}
